package main

import "fmt"

func calc(taskChan chan int, resChan chan int) {
	for v := range taskChan {
		flag := true
		for i := 3; i < v; i++ {
			if v%i == 0 {
				flag = false
				break
			}
		}
		if flag {
			resChan <- v
		}
	}
}

func main() {
	intChan := make(chan int, 1000)
	resChan := make(chan int, 1000)
	for i := 0; i < 100000; i++ {
		intChan <- i
	}

	for i := 0; i < 8; i++ {
		go calc(intChan, resChan)
	}

	for v := range resChan {
		fmt.Println(v)
	}
}
